#pragma once

#include "Comp.h"
#include "ThreeMaxLoader.h"

using namespace std;

class DSXLoader
{
public:

	map < string, material > Materials;
	map < string, texture > Textures;
	map < string, spot > LightsSpot;
	map < string, omni > LightsOmni;
	map < string, Primitive* > Primitives;
	map < string, TransformationSet > Transf;
	map < string, Comp > comp;
	map < string, perspective > perspectives;
	map < string, ortho > orthos;
	multimap< char , string > materialKeys;

	stack< pair<string,string> > childComponent;
	DSXLoader(const char* filename);
	bool Load();
	void loadScene();
	void loadViews();
	void loadIllumination();
	void loadLights();
	void loadMaterials();
	void loadTextures();
	void loadPrimitives();
	void loadTransformations();
	void loadComps();
	void draw();
	void draw(string compName);
	void change_views();
	void updatePerspectives(perspective * p,bool picking);
	void updateOrthos(ortho * o, bool picking);
	
	string active;
	float axisscale;
	string rootName;
	string views_default;
	perspective pres;
	ortho ort;
	illumination ill;
	RGBpixmap pixmap;
	void enableLights();
	void nextMaterial(const char key);
	
private:
	TiXmlElement* rootElement;
	TiXmlElement* sceneElement;
	TiXmlElement* viewsElement;
	TiXmlElement* illumElement;
	TiXmlElement* lightsElement;
	TiXmlElement* texturesElement;
	TiXmlElement* materialsElement; 
	TiXmlElement* transfElement; 
	TiXmlElement* primitivesElement;
	TiXmlElement* componentsElement;

	TiXmlElement* perspectiveElement;
	TiXmlElement* orthoElement;
	TiXmlDocument doc;
};